/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Model.MonitorInfo;
import Model.Statistics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;

/**
 *
 * @author elach_000
 */
public class MonitorView extends JPanel implements Observer {

    private javax.swing.JLabel activityLabel;
    private javax.swing.JPanel agentPanel;
    private javax.swing.JLabel amountLabel;
    private javax.swing.JLabel beingDestination;
    private javax.swing.JLabel beingLabel;
    private javax.swing.JLabel beingPosition;
    private javax.swing.JLabel beingPositionLabel;
    private javax.swing.JLabel beingTypeLabel;
    private javax.swing.JLabel clanInformationsLabel;
    private javax.swing.JPanel clanPanel;
    private javax.swing.JLabel clanResourceLabel;
    private javax.swing.JLabel destinationLabel;
    private javax.swing.JProgressBar goldProgressBar;
    private javax.swing.JTextField idTextField;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JSeparator jSeparator;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JLabel memoryFoodLabel;
    private javax.swing.JTextField memoryFoodTextField;
    private javax.swing.JLabel memoryLabel;
    private javax.swing.JLabel memoryStoneLabel;
    private javax.swing.JTextField memoryStoneTextField;
    private javax.swing.JLabel memoryWaterLabel;
    private javax.swing.JTextField memoryWaterTextField;
    private javax.swing.JLabel memoryWoodLabel;
    private javax.swing.JTextField memoryWoodTextField;
    private javax.swing.JTabbedPane monitorTabbedPane;
    private javax.swing.JLabel nbCows;
    private javax.swing.JLabel nbDeadAnimals;
    private javax.swing.JLabel nbDeadVillagers;
    private javax.swing.JLabel nbDoes;
    private javax.swing.JLabel nbFoodLabel;
    private javax.swing.JTextField nbFoodTextField;
    private javax.swing.JLabel nbLions;
    private javax.swing.JLabel nbSteps;
    private javax.swing.JLabel nbStoneLabel;
    private javax.swing.JTextField nbStoneTextField;
    private javax.swing.JLabel nbWaterLabel;
    private javax.swing.JTextField nbWaterTextField;
    private javax.swing.JLabel nbWoodLabel;
    private javax.swing.JTextField nbWoodTextField;
    private javax.swing.JButton nextButton;
    private javax.swing.JLabel population;
    private javax.swing.JLabel populationLabel;
    private javax.swing.JButton previousButton;
    private javax.swing.JLabel resourceLabel;
    private javax.swing.JTextField resourceTypeTextBox;
    private javax.swing.JProgressBar ressourceProgressBar;
    private javax.swing.JLabel ressourceTypeLabel;
    private javax.swing.JLabel statAnimalLabel;
    private javax.swing.JPanel statsPanel;
    private javax.swing.JProgressBar stoneProgressBar;
    private javax.swing.JProgressBar waterProgressBar;
    private javax.swing.JProgressBar woodProgressBar;
    private Model.Game game;

    public MonitorView() {
        initComponents();
    }

    public void setGame(Model.Game game) {
        this.game = game;
        this.showID(0);
        this.idTextField.setText("" + 0);
    }

    private void initComponents() {
        monitorTabbedPane = new javax.swing.JTabbedPane();
        agentPanel = new javax.swing.JPanel();
        jSeparator = new javax.swing.JSeparator();
        idTextField = new javax.swing.JTextField();
        previousButton = new javax.swing.JButton();
        nextButton = new javax.swing.JButton();
        beingTypeLabel = new javax.swing.JLabel();
        activityLabel = new javax.swing.JLabel();
        ressourceProgressBar = new javax.swing.JProgressBar();
        resourceLabel = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        ressourceTypeLabel = new javax.swing.JLabel();
        resourceTypeTextBox = new javax.swing.JTextField();
        amountLabel = new javax.swing.JLabel();
        beingPositionLabel = new javax.swing.JLabel();
        beingPosition = new javax.swing.JLabel();
        destinationLabel = new javax.swing.JLabel();
        beingDestination = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        beingLabel = new javax.swing.JLabel();
        clanPanel = new javax.swing.JPanel();
        nbWaterTextField = new javax.swing.JTextField();
        clanResourceLabel = new javax.swing.JLabel();
        nbWaterLabel = new javax.swing.JLabel();
        nbWoodLabel = new javax.swing.JLabel();
        population = new javax.swing.JLabel();
        nbStoneTextField = new javax.swing.JTextField();
        clanInformationsLabel = new javax.swing.JLabel();
        nbStoneLabel = new javax.swing.JLabel();
        nbFoodLabel = new javax.swing.JLabel();
        nbFoodTextField = new javax.swing.JTextField();
        populationLabel = new javax.swing.JLabel();
        nbWoodTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator5 = new javax.swing.JSeparator();
        memoryLabel = new javax.swing.JLabel();
        memoryFoodLabel = new javax.swing.JLabel();
        memoryFoodTextField = new javax.swing.JTextField();
        memoryWaterLabel = new javax.swing.JLabel();
        memoryWaterTextField = new javax.swing.JTextField();
        memoryWoodLabel = new javax.swing.JLabel();
        memoryWoodTextField = new javax.swing.JTextField();
        memoryStoneLabel = new javax.swing.JLabel();
        memoryStoneTextField = new javax.swing.JTextField();
        statsPanel = new javax.swing.JPanel();
        statAnimalLabel = new javax.swing.JLabel();
        jSeparator6 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        nbDoes = new javax.swing.JLabel();
        nbLions = new javax.swing.JLabel();
        nbCows = new javax.swing.JLabel();
        nbDeadAnimals = new javax.swing.JLabel();
        jSeparator7 = new javax.swing.JSeparator();
        jLabel11 = new javax.swing.JLabel();
        nbDeadVillagers = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jSeparator8 = new javax.swing.JSeparator();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jSeparator9 = new javax.swing.JSeparator();
        jLabel20 = new javax.swing.JLabel();
        nbSteps = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        woodProgressBar = new javax.swing.JProgressBar();
        goldProgressBar = new javax.swing.JProgressBar();
        stoneProgressBar = new javax.swing.JProgressBar();
        waterProgressBar = new javax.swing.JProgressBar();

        setFocusable(false);

        monitorTabbedPane.setFocusable(false);

        agentPanel.setFocusable(false);

        idTextField.setText("0");
        idTextField.setFocusable(false);

        previousButton.setText("<");
        previousButton.setFocusable(false);

        nextButton.setText(">");
        nextButton.setFocusable(false);

        beingTypeLabel.setText("Type");
        beingTypeLabel.setFocusable(false);

        activityLabel.setText("Activity");
        activityLabel.setFocusable(false);

        ressourceProgressBar.setMaximum(15);
        ressourceProgressBar.setFocusable(false);
        ressourceProgressBar.setStringPainted(true);

        resourceLabel.setText("Ressource portée :");
        resourceLabel.setFocusable(false);

        jCheckBox1.setText("Vivant");

        ressourceTypeLabel.setText("Type");
        ressourceTypeLabel.setFocusable(false);

        resourceTypeTextBox.setText("Rien");
        resourceTypeTextBox.setFocusable(false);

        amountLabel.setText("Quantité");
        amountLabel.setFocusable(false);

        beingPositionLabel.setText("Position : ");
        beingPositionLabel.setFocusable(false);

        beingPosition.setText("X,Y");
        beingPosition.setFocusable(false);

        destinationLabel.setText("Destination : ");
        destinationLabel.setFocusable(false);

        beingDestination.setText("Aucune");
        beingDestination.setFocusable(false);

        beingLabel.setText("Informations Agent");
        beingLabel.setFocusable(false);

        javax.swing.GroupLayout agentPanelLayout = new javax.swing.GroupLayout(agentPanel);
        agentPanel.setLayout(agentPanelLayout);
        agentPanelLayout.setHorizontalGroup(
                agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(beingTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(previousButton))
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nextButton)
                .addGap(1, 1, 1))
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(activityLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))))
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(amountLabel)
                .addComponent(ressourceTypeLabel))
                .addGap(18, 18, 18)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(resourceTypeTextBox)
                .addComponent(ressourceProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addComponent(resourceLabel)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addComponent(beingPositionLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(beingPosition))
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addComponent(destinationLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(beingDestination))
                .addComponent(jCheckBox1)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(beingLabel)
                .addComponent(jSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 0, 0)))
                .addContainerGap()));
        agentPanelLayout.setVerticalGroup(
                agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(agentPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(beingLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(previousButton)
                .addComponent(nextButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(beingTypeLabel)
                .addComponent(activityLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(resourceLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(ressourceTypeLabel)
                .addComponent(resourceTypeTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(amountLabel)
                .addComponent(ressourceProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(beingPositionLabel)
                .addComponent(beingPosition))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(agentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(destinationLabel)
                .addComponent(beingDestination))
                .addContainerGap(196, Short.MAX_VALUE)));

        monitorTabbedPane.addTab("Agent", agentPanel);

        clanPanel.setFocusable(false);

        nbWaterTextField.setText("0");
        nbWaterTextField.setFocusable(false);

        clanResourceLabel.setText("Ressources");
        clanResourceLabel.setFocusable(false);

        nbWaterLabel.setText("Eau");
        nbWaterLabel.setFocusable(false);

        nbWoodLabel.setText("Bois");
        nbWoodLabel.setFocusable(false);

        population.setText("0");
        population.setFocusable(false);

        nbStoneTextField.setText("0");
        nbStoneTextField.setFocusable(false);

        clanInformationsLabel.setText("Informations Générales");
        clanInformationsLabel.setFocusable(false);

        nbStoneLabel.setText("Pierre");
        nbStoneLabel.setFocusable(false);

        nbFoodLabel.setText("Nourriture");
        nbFoodLabel.setFocusable(false);

        nbFoodTextField.setText("0");
        nbFoodTextField.setFocusable(false);

        populationLabel.setText("Population : ");
        populationLabel.setFocusable(false);

        nbWoodTextField.setText("0");
        nbWoodTextField.setFocusable(false);

        jLabel1.setText("QG :");
        jLabel1.setFocusable(false);

        jLabel2.setText("X,Y");
        jLabel2.setFocusable(false);

        memoryLabel.setText("Contenu Mémoire Commune");
        memoryLabel.setToolTipText("Nombre de cases connues contenant la ressource");
        memoryLabel.setFocusable(false);

        memoryFoodLabel.setText("Nourriture");
        memoryFoodLabel.setFocusable(false);
        memoryFoodLabel.setInheritsPopupMenu(false);

        memoryFoodTextField.setText("0");
        memoryFoodTextField.setToolTipText("Nombre de cases connues contenant la ressource");
        memoryFoodTextField.setFocusable(false);

        memoryWaterLabel.setText("Eau");
        memoryWaterLabel.setFocusable(false);

        memoryWaterTextField.setText("0");
        memoryWaterTextField.setToolTipText("Nombre de cases connues contenant la ressource");
        memoryWaterTextField.setFocusable(false);

        memoryWoodLabel.setText("Bois");
        memoryWoodLabel.setFocusable(false);

        memoryWoodTextField.setText("0");
        memoryWoodTextField.setToolTipText("Nombre de cases connues contenant la ressource");
        memoryWoodTextField.setFocusable(false);

        memoryStoneLabel.setText("Pierre");
        memoryStoneLabel.setFocusable(false);

        memoryStoneTextField.setText("0");
        memoryStoneTextField.setToolTipText("Nombre de cases connues contenant la ressource");
        memoryStoneTextField.setFocusable(false);

        javax.swing.GroupLayout clanPanelLayout = new javax.swing.GroupLayout(clanPanel);
        clanPanel.setLayout(clanPanelLayout);
        clanPanelLayout.setHorizontalGroup(
                clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(memoryLabel))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(memoryStoneLabel)
                .addGap(39, 39, 39)
                .addComponent(memoryStoneTextField))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(memoryFoodLabel)
                .addGap(18, 18, 18)
                .addComponent(memoryFoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(memoryWaterLabel)
                .addGap(49, 49, 49)
                .addComponent(memoryWaterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(memoryWoodLabel)
                .addGap(48, 48, 48)
                .addComponent(memoryWoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14))
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addComponent(populationLabel)
                .addGap(18, 18, 18)
                .addComponent(population, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(nbFoodLabel)
                .addComponent(nbWaterLabel)
                .addComponent(nbWoodLabel)
                .addComponent(nbStoneLabel)
                .addComponent(jLabel1))
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(nbWaterTextField)
                .addComponent(nbWoodTextField)
                .addComponent(nbStoneTextField)
                .addComponent(nbFoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel2))))
                .addComponent(clanInformationsLabel, javax.swing.GroupLayout.Alignment.TRAILING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, clanPanelLayout.createSequentialGroup()
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(clanResourceLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator4))
                .addGap(36, 36, 36)))))))
                .addGap(24, 24, 24)));
        clanPanelLayout.setVerticalGroup(
                clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(clanPanelLayout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(clanInformationsLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(populationLabel)
                .addComponent(population))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1)
                .addComponent(jLabel2))
                .addGap(13, 13, 13)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(clanResourceLabel)
                .addGap(11, 11, 11)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(nbFoodLabel)
                .addComponent(nbFoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(nbWaterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(nbWaterLabel, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(nbWoodLabel)
                .addComponent(nbWoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(nbStoneLabel)
                .addComponent(nbStoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(memoryLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(memoryFoodLabel)
                .addComponent(memoryFoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(memoryWaterLabel)
                .addComponent(memoryWaterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(memoryWoodLabel)
                .addComponent(memoryWoodTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(clanPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(memoryStoneLabel)
                .addComponent(memoryStoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(72, Short.MAX_VALUE)));

        monitorTabbedPane.addTab("Clan", clanPanel);

        statsPanel.setFocusable(false);

        statAnimalLabel.setText("Animaux");
        statAnimalLabel.setFocusable(false);

        jLabel3.setText("Nb Biches ");
        jLabel3.setFocusable(false);

        jLabel4.setText("Nb Lions");
        jLabel4.setFocusable(false);

        jLabel5.setText("Nb Vaches");
        jLabel5.setFocusable(false);

        jLabel6.setText("Nb Animaux morts");
        jLabel6.setFocusable(false);

        nbDoes.setText("0");
        nbDoes.setFocusable(false);

        nbLions.setText("0");
        nbLions.setFocusable(false);

        nbCows.setText("0");
        nbCows.setFocusable(false);

        nbDeadAnimals.setText("0");
        nbDeadAnimals.setFocusable(false);

        jLabel11.setText("Nb Villageois morts");
        jLabel11.setFocusable(false);

        nbDeadVillagers.setText("0");
        nbDeadVillagers.setFocusable(false);

        jLabel13.setText("Ressources disponibles");
        jLabel13.setFocusable(false);

        jLabel14.setText("Bois");
        jLabel14.setFocusable(false);

        jLabel15.setText("Or");
        jLabel15.setFocusable(false);

        jLabel16.setText("Pierre");
        jLabel16.setFocusable(false);

        jLabel20.setText("Nb Tours");
        jLabel20.setFocusable(false);

        nbSteps.setText("0");
        nbSteps.setFocusable(false);

        jLabel7.setText("Eau");

        woodProgressBar.setStringPainted(true);

        goldProgressBar.setStringPainted(true);

        stoneProgressBar.setMaximum(Statistics.getNbMapStone());
        stoneProgressBar.setStringPainted(true);

        waterProgressBar.setStringPainted(true);

        javax.swing.GroupLayout statsPanelLayout = new javax.swing.GroupLayout(statsPanel);
        statsPanel.setLayout(statsPanelLayout);
        statsPanelLayout.setHorizontalGroup(
                statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(statAnimalLabel)))
                .addContainerGap())
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel3)
                .addComponent(jLabel4)
                .addComponent(jLabel5))
                .addGap(55, 55, 55)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(nbCows, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
                .addComponent(nbLions, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(nbDoes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addComponent(nbDeadAnimals, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel15)
                .addComponent(jLabel14)
                .addComponent(jLabel16)
                .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(goldProgressBar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
                .addComponent(woodProgressBar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addComponent(stoneProgressBar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addComponent(waterProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel11)
                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(nbDeadVillagers, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addComponent(jLabel20)
                .addGap(18, 18, 18)
                .addComponent(nbSteps, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel13)))
                .addGap(0, 0, Short.MAX_VALUE)));
        statsPanelLayout.setVerticalGroup(
                statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statAnimalLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel3)
                .addComponent(nbDoes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4)
                .addComponent(nbLions))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel5)
                .addComponent(nbCows))
                .addGap(9, 9, 9)
                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel6)
                .addComponent(nbDeadAnimals))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel11)
                .addComponent(nbDeadVillagers))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statsPanelLayout.createSequentialGroup()
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel14)
                .addComponent(woodProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel15)
                .addComponent(goldProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel16))
                .addComponent(stoneProgressBar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel7)
                .addComponent(waterProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addComponent(jSeparator9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(nbSteps)
                .addComponent(jLabel20))
                .addContainerGap(82, Short.MAX_VALUE)));

        monitorTabbedPane.addTab("Statistiques", statsPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(monitorTabbedPane));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(monitorTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE));

        stoneProgressBar.setMaximum(Statistics.getNbMapStone());
        waterProgressBar.setMaximum(Statistics.getNbMapWater());
        woodProgressBar.setMaximum(Statistics.getNbMapWood());
        goldProgressBar.setMaximum(Statistics.getNbMapGold());

        previousButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                int id = Integer.parseInt(idTextField.getText());
                id = Tools.clamp(id - 1, 0, game.getNumberTotalOfBeings() - 1);
                idTextField.setText("" + id);
                showID(id);
            }
        });

        nextButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                try {
                    int id = Integer.parseInt(idTextField.getText());
                    id = Tools.clamp(id + 1, 0, game.getNumberTotalOfBeings() - 1);
                    idTextField.setText("" + id);
                    showID(id);
                } catch (Exception e) {
                    showID(0);
                }
            }
        });

        idTextField.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                int id = Integer.parseInt(idTextField.getText());
                id = Tools.clamp(id, 0, game.getNumberTotalOfBeings() - 1);
                idTextField.setText("" + id);
                showID(id);
            }
        });


    }

    public void update(Observable o, Object arg) {
        if (arg == null) {
            try {
                this.showID(Integer.parseInt(idTextField.getText()));
                this.majClan();
                this.majStats();
            } catch (Exception e) {
                this.showID(0);
            }

        } else {
            MonitorInfo info = (MonitorInfo) arg;

            String newValue = info.getValue();
            String infoType = info.getType();

            if (infoType.equals("clanFood")) {
                this.nbFoodTextField.setText(newValue);
            } else if (infoType.equals("clanWood")) {
                this.nbWoodTextField.setText(newValue);
            } else if (infoType.equals("clanStone")) {
                this.nbStoneTextField.setText(newValue);
            } else if (infoType.equals("clanWater")) {
                this.nbWaterTextField.setText(newValue);
            }
        }

    }

    public void majStats() {
        this.nbSteps.setText("" + Statistics.getNbSteps());

        this.nbDoes.setText("" + Statistics.getNbDoes());
        this.nbLions.setText("" + Statistics.getNbLions());
        this.nbCows.setText("" + Statistics.getNbCows());

        this.nbDeadAnimals.setText("" + Statistics.getNbDeadAnimals());
        this.nbDeadVillagers.setText("" + Statistics.getNbDeadVillagers());

        this.woodProgressBar.setValue(Statistics.getNbMapWood());
        this.waterProgressBar.setValue(Statistics.getNbMapWater());
        this.goldProgressBar.setValue(Statistics.getNbMapGold());
        this.stoneProgressBar.setValue(Statistics.getNbMapStone());

    }

    public void majClan() {

        Model.Clan clan = this.game.getClanList().get(0);
        this.population.setText("" + clan.getVillagerList().size());
        this.jLabel2.setText(clan.getSquareQG().getLocation().getXPosition() + "," + clan.getSquareQG().getLocation().getXPosition());
        this.memoryFoodTextField.setText("" + clan.getClanMemory().getAnimals().size());
        this.memoryWaterTextField.setText("" + clan.getClanMemory().getWater().size());
        this.memoryStoneTextField.setText("" + clan.getClanMemory().getStone().size());
        this.memoryWoodTextField.setText("" + clan.getClanMemory().getWood().size());
    }

    public void showID(int id) {
        Model.Being b = game.getBeingFromId(id);
        if (b == null) {
            idTextField.setText("" + id);

            beingTypeLabel.setText("Type");
            activityLabel.setText("Activity");

            jCheckBox1.setSelected(false);

            resourceTypeTextBox.setText("Rien");
            ressourceProgressBar.setValue(0);

            beingPosition.setText("X,Y");
            beingDestination.setText("Aucune");
        } else {
            if (b.isAnimal()) {
                beingTypeLabel.setText("Animal");
                activityLabel.setText(((Model.Animal) b).getType().name());
                ressourceProgressBar.setMaximum(50);
            } else {
                beingTypeLabel.setText("Villageois");
                activityLabel.setText(((Model.Villager) b).getActivity().name());
                ressourceProgressBar.setMaximum(15);
            }

            jCheckBox1.setSelected(b.isAlive());

            resourceTypeTextBox.setText(b.getResourceBrought().getType().name());
            ressourceProgressBar.setValue(b.getResourceBrought().getAmount());

            beingPosition.setText(b.getLocation().getXPosition() + "," + b.getLocation().getYPosition());
            if (b.getTarget() != null) {
                beingDestination.setText(b.getTarget().getXPosition() + "," + b.getTarget().getYPosition());
            } else {
                beingDestination.setText("Aucune");
            }

        }
    }
}
